import _regeneratorRuntime from "@babel/runtime/regenerator";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";

/*
 * uomTypeService - 单位类型定义
 * @date: 2018/10/13 10:42:04

 */
import request from 'utils/request';
import { CPAAS_PLATFORM } from 'utils/config';
import { parseParameters, getCurrentOrganizationId, isTenantRoleLevel } from 'utils/utils';
/**
 * 查询单位类型定义列表
 */

export function fetchUomList(_x) {
  return _fetchUomList.apply(this, arguments);
}
/**
 * @export
 * @param {*} params
 * @returns 请求添加单位类型定义的结果
 */

function _fetchUomList() {
  _fetchUomList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(params) {
    return _regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            return _context.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1").concat(isTenantRoleLevel() ? "/".concat(getCurrentOrganizationId()) : '', "/uom-types"), {
              method: 'GET',
              query: parseParameters(params)
            }));

          case 1:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));
  return _fetchUomList.apply(this, arguments);
}

export function addUom(_x2) {
  return _addUom.apply(this, arguments);
}

function _addUom() {
  _addUom = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(params) {
    return _regeneratorRuntime.wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            return _context2.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1").concat(isTenantRoleLevel() ? "/".concat(getCurrentOrganizationId()) : '', "/uom-types"), {
              method: 'POST',
              body: [params]
            }));

          case 1:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2);
  }));
  return _addUom.apply(this, arguments);
}